//
//  DataManager.h
//  OrderOnline
//
//  Created by YAPPA_3 on 11/30/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Downloader.h"
#import "CacheController.h"
#import "DMCurrentInfo.h"
#import "OrderXmlParser.h"

typedef enum
{
	
	eDmtInvalid = -1,
	eDmtMenuFoodXml,	
	eDmtMax,
	
}eDataManagerType;

@interface NSData(extend)
- (NSData*)convertXml;
@end


@interface DataManager : NSObject {

	DMCurrentInfo*		m_Current;
	CacheController*	m_CacheManager;
	Downloader*			m_Downloader;
	OrderXmlParser*		    m_XmlParser;	
	NSMutableArray*		m_DMUnits;
	BOOL				m_IsOffline;
	
	//data
	NSMutableArray* m_listOrder;
	NSMutableArray* m_listOrderCount;
	//
	Order*	m_order;
}

@property(nonatomic, readonly) DMCurrentInfo*		m_Current;
@property(nonatomic, readonly) CacheController*		m_CacheManager;
@property(nonatomic, readonly) Downloader*			m_Downloader;
@property(nonatomic, readonly) OrderXmlParser*		m_XmlParser;	
@property(nonatomic)		   BOOL					m_IsOffline;
@property(nonatomic, retain) NSMutableArray* m_listOrder;
@property(nonatomic, retain) NSMutableArray* m_listOrderCount;
@property(nonatomic, retain) Order*	m_order;


- (NSString *)createServerPath:(NSString *)path;
- (NSString *)createServerPath:(NSString *)path current:(DMCurrentInfo*)current;
- (BOOL)isExistInResource:(NSString *)url;
- (NSData *)loadFromResource:(NSString *)url;
- (id)getDMUnit:(eDataManagerType)dmtype;
- (void)update;
- (BOOL) addFoodToListOrder: (Food*) food count: (int) countNum;
- (void) saveFoodToListOrder;
- (void) loadFoodToListOrder;
- (BOOL) addFoodToOrder: (Food*) food count: (int) countNum;
- (void) resetOrder;
- (void) removeFoodFromOrder: (NSString*) productID;
- (void) editFoodFromOrder: (NSString*) productID count: (int) countNum;

+ (DataManager *)Shared;
@end
